Two Dimensional Plots:
    Function Plots | Countour Plots | Velocity Fields | Manipulating the Devices | Java Device

    MANIPULATING THE DEVICES

    - manipulation of the X-11 graphic devices in Xi -

    In the previous examples we used the X-graphic device without using any manipulating functions. Let's return to our beginning example. We want to compare the Sine and Cosine function. Instead of putting two plots together in a single device like in the first example we can also open up two devices. We begin in the same way as in example 1. First subdivide the interval -10 to 10 into 500 pieces and calculate the Sine:

    (  1)>x=interval(-10,10,500);
    (  2)>y=sin(x);
    
    Now open up the first X-device and plot the sine:
    (  3)>window(0);
    (  4)>plot(x,y,\yrange={-1,1},\xtitle="x",\ytitle="y",\line);
    
    Instead of putting a title above the plot we now change the title of the X-window:
    (  5)>window(\title="The Sine function");
    
    Let's calculate the Cosine
    (  6)>y=cos(x);
    
    open up the second X-device
    (  7)>window(1);
    
    plot the Cosine function inside
    (  8)>plot(x,y,\yrange={-1,1},\xtitle="x",\ytitle="y",\line);
    
    and finally change the title of that new X-window:
    (  9)>window(\title="The Cosine function");
    
    The sizes and positions are not very satisfactory yet. Let's move and resize them (perhaps your mouse is tired :-). We begin with the first window:
    ( 10)>window(0,\position={10,10},\size={400,400});
    
    Next the second window:
    ( 11)>window(1,\position={410,10},\size={400,400});
    
    Now where we've played enough with the X-device, we should close both windows and start something new:
    ( 12)>window(0,\close);
    ( 13)>window(1,\close);
    
    We want two ppm-files of the above plots. Let's open a PPM-defice with 500x500 pixels:
    ( 14)>window(0,\size={500,500},\ppm);
    
    Calculate and plot the Sine function:
    ( 15)>y=sin(x);
    ( 16)>plot(x,y,\yrange={-1,1},\xtitle="x",\ytitle="y",\line);
    
    Now that we have the whole plot - let's save it. First we have to choose a good name for the file:
    ( 17)>window(0,\name="sine.ppm",\ppm);
    
    Note that here the ppm argument has to be set too (this will be possibly changed some time). The file will be automatically saved when the device is closed:
    ( 18)>window(0,\close);
    
    And the same with the Cosine:
    ( 19)>window(0,\name="cosine.ppm",\size={500,500},\ppm);
    ( 20)>y=cos(x);
    ( 21)>plot(x,y,\yrange={-1,1},\xtitle="x",\ytitle="y",\line);
    ( 22)>window(0,\close);
    
    Of course all the action mentioned can be done with the mouse and the suitable buttons on the X-window too.


    Rechts Index Index Index Linls © 1995 by Bodo Junglas, Klaus Spanderen and Fabian Weis
    - Last revised: April 23 1996